﻿package mortal.game.view.friend
{
    import Message.Client.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class FriendApplyCellRenderer extends GCellRenderer
    {
        private var _roleName:GTextFiled;
        private var _roleLevel:GTextFiled;
        private var _applyMsg:GTextFiled;
        private var _okBtn:GButton;
        private var _cancelBtn:GButton;
        private var _spliteLine:ScaleBitmap;
        private var _player:SMiniPlayer;

        public function FriendApplyCellRenderer()
        {
            this.setSize(153, 25);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._roleName = UIFactory.gTextField("", 57 - 35, 11, 51 + 45, 23, this);
            this._roleName.configEventListener(TextEvent.LINK, this.onTextClickHandler);
            this._roleName.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._roleName.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._roleLevel = UIFactory.gTextField("", 113 - 35, 11, 66, 23, this, GlobalStyle.textFormatHuang);
            this._applyMsg = UIFactory.gTextField(Language.getString(41210), 22, 42, 215, 23, this);
            this._applyMsg.textColor = GlobalStyle.colorBaiUint;
            this._okBtn = UIFactory.gButton(Language.getString(41211), 245, 12, 51, 23, this);
            this._cancelBtn = UIFactory.gButton(Language.getString(41212), 245, 39, 51, 23, this);
            this._spliteLine = UIFactory.bg(22, 70, 246, 1, this, ImagesConst.SplitLine);
            this._okBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._cancelBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._roleName.dispose(param1);
            this._roleLevel.dispose(param1);
            this._applyMsg.dispose(param1);
            this._okBtn.dispose(param1);
            this._cancelBtn.dispose(param1);
            this._spliteLine.dispose(param1);
            this._roleName = null;
            this._roleLevel = null;
            this._applyMsg = null;
            this._okBtn = null;
            this._cancelBtn = null;
            this._spliteLine = null;
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SMiniPlayer = null;
            if (param1 != null)
            {
                _loc_2 = param1 as SMiniPlayer;
                this._player = _loc_2;
                this._roleName.htmlText = HTMLUtil.addLink(_loc_2.name, GlobalStyle.colorBai);
                this._roleLevel.text = Language.getStringByParam(41213, _loc_2.level);
                this._roleLevel.x = this._roleName.x + this._roleName.width + 5;
            }
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = new Object();
            var _loc_4:* = new Array();
            if (event.target == this._okBtn)
            {
                _loc_2 = EFriendReplyResult._EFriendReplyResultAccept;
            }
            else if (event.target == this._cancelBtn)
            {
                _loc_2 = EFriendReplyResult._EFriendReplyResultReject;
            }
            _loc_4.push(this._player.entityId.id);
            _loc_3["result"] = _loc_2;
            _loc_3["playerId"] = _loc_4;
            Dispatcher.dispatchEvent(new DataEvent(EventName.FriendReply, _loc_3));
            return;
        }// end function

        private function onTextClickHandler(event:TextEvent) : void
        {
            var _loc_2:* = ELookUpType._ELookUpTypePlayer;
            GameProxy.chat.lookupRequest(ELookRoleInfoType._ECommonRoleInfo, this._player.entityId, _loc_2);
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

    }
}
